package com.sbl.bajw.common;

import java.util.Properties;

import org.apache.ibatis.executor.resultset.FastResultSetHandler;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;

@Intercepts({@org.apache.ibatis.plugin.Signature(type=org.apache.ibatis.executor.resultset.ResultSetHandler.class, method="handleResultSets", args={java.sql.Statement.class})})
public class ResultInterceptor implements Interceptor {


  public Object intercept(Invocation invocation) throws Throwable {
    FastResultSetHandler resultSet = (FastResultSetHandler)invocation.getTarget();
    MappedStatement mappedStatement = (MappedStatement)ReflectUtils.getValueByFieldName(resultSet, "mappedStatement");
    ResultSetType resultSetType = mappedStatement.getResultSetType();
    System.out.println(resultSetType);
    return invocation.proceed();
  }

  public Object plugin(Object target)
  {
    return Plugin.wrap(target, this);
  }

	@Override
	public void setProperties(Properties arg0) {
		
	}

}